package com.fulin.leetcode;

/**
 * 最后一个单词的长度
 *
 * @Author fulin
 * @Date 2022/9/16 12:29
 **/
public class Num58 {
    public int lengthOfLastWord(String s) {
        int len = s.length();
        int end = len - 1;
        char R = s.charAt(end);
        while(R == ' '){
            end --;
        }

        int start = end;
        char L = s.charAt(start);
        while(L != ' '){
            start --;
        }
        return end - start;
    }
}
